<?php
/**
 *
 * @package 
 * @since 1.0
 */
 
 
/**
 *
 +--------------------------------------------------
 * 获取广告代码
 +--------------------------------------------------
 * @param $atype	广告名
 +--------------------------------------------------
 * @return string	广告代码
 +--------------------------------------------------
 */
function getad($title){
	assert ( is_string($title) );
	
	$data = M('advance')->where("title='".$title."'")->field('url,pic')->find();
	if($data){
		$html = "<a href='".$data['url']."'><img src='".$data['pic']."' /></a>";
	}else{
	    $html = NULL;
	}

	return $html;
}

/**
 *
 +--------------------------------------------------
 * 获取banner图代码
 +--------------------------------------------------
 * @author wangcheng	<360954149@qq.com>
 +--------------------------------------------------
 * @param $title	广告名
 +--------------------------------------------------
 * @return string	广告代码
 +--------------------------------------------------
 */
function getbanner($title){
	assert ( is_string($title) );
	
	$data = M('banner')->where("location='".$title."'")->field('url,pic')->find();
	if($data){
	    if(empty($data['url'])){
			$html = "<img src='".$data['pic']."' />";
		}else{
			$html = "<a href='".$data['url']."'><img src='".$data['pic']."' /></a>";
		}

	}else{
	    $html = NULL;
	}
	return $html;
}

